package com.chinasofti.login.service.impl;

import java.util.List;

import com.chinasofti.login.entity.User;
import com.chinasofti.login.service.LoginService;
import com.chinasofti.login.vo.RsObject;
import com.chinasofti.util.ConnectionDB;

public class LoginServiceImpl implements LoginService{

	@Override
	public RsObject checkUser(User user) throws Exception {
		RsObject rsObject = new RsObject();
		User rs = null;
		ConnectionDB conn = new ConnectionDB();
		String sql = "select * from t_user where user_name = ? ";
		Object[] params = {user.getUserName()};
		List<Object> list = conn.excuteQuery(sql, params, User.class);
		if(list!=null){
			rs = (User) list.get(0);
		}
		if(rs==null){
			rsObject.setMsg("用户名不正确");
			return rsObject;
		}
		if(!user.getPassWord().equals(rs.getPassWord())){
			rsObject.setMsg("密码不正确");
		}
		rsObject.setSuccess(true);
		rsObject.setMsg("登陆成功");
		rsObject.setObject(rs);
		return rsObject;
	}

}
